<template>
	<view class="">
		<view class="item-con">
			<view class="item-title pad">申请投资区域</view>
			<view class="item-input pad flex-row items-center justify-between" @click="show=true">
				<input class="fill  input" disabled type="text" value="" v-model="form.address" placeholder="请选择" />
				<u-icon name="arrow-right" size="24" color="#999999"></u-icon>
			</view>
		</view>
		<view class="item-con">
			<view class="item-title pad">投资预算</view>
			<view class="item-input pad flex-row items-center justify-between" @click="moneyPicker=true">
				<input class="fill  input" disabled type="text" value="" v-model="form.money" placeholder="请选择" />
				<u-icon name="arrow-right" size="24" color="#999999"></u-icon>
			</view>
		</view>
		<view class="item-con">
			<view class="item-title pad">联系人</view>
			<view class="item-input pad flex-row items-center justify-between">
				<input class="fill  input" type="text" v-model="form.name" value="" placeholder="请输入" />
				<u-icon name="arrow-right" size="24" color="#999999"></u-icon>
			</view>
		</view>
		<view class="item-con">
			<view class="item-title pad">联系电话</view>
			<view class="item-input pad flex-row items-center justify-between">
				<input class="fill  input" type="number" maxlength="11" v-model="form.phone" value="" placeholder="请输入" />
				<u-icon name="arrow-right" size="24" color="#999999"></u-icon>
			</view>
		</view>
		<view class="item-con">
			<view class="item-title pad">备注</view>
			<view class="item-textarea"><textarea class="textarea" v-model="form.remarks" placeholder="请输入"></textarea></view>
		</view>
		<view class="btn" hover-class="hover-opacity" @click="submit">提交</view>
		<mix-modal-s ref="mixModalS" @onConfirm="back"></mix-modal-s>
		<mix-loading v-if="isLoading"></mix-loading>
		<u-picker mode="region" v-model="show" @confirm="pickerConfirm"></u-picker>
		<u-picker mode="selector" :range="investmentList" v-model="moneyPicker" @confirm="moneyConfirm"></u-picker>
	</view>
</template>

<script>
import { checkStr } from '@/common/js/util.js';
export default {
	data() {
		return {
			show: false,
			moneyPicker:false,
			content: '',
			form: {
				uid:uni.getStorageSync('uid'),
				money:'',
				address: '',
				province: '',
				city: '',
				county: '',
				name: '',
				phone: '',
				remarks: ''
			}
		};
	},
	methods: {
		moneyConfirm(array){
			let index=array[0];
			this.form.money=this.investmentList[index];
		},
		pickerConfirm(e) {
			console.log(e);
			let address = e.province.label;
			if (e.city.label != '市辖区') {
				address += e.city.label;
				this.form.city = e.city.label;
			}
			if (e.area.label != e.city.label) {
				address += e.area.label;
				this.form.county = e.area.label;
			}
			this.form.province = e.province.label;
			this.form.address = address;
		},
		async submit() {
			const { province,money, name, phone, remarks } = this.form;
			if (province == '') {
				this.$util.msg('请选区域!');
				return;
			}
			if (money == '') {
				this.$util.msg('请选择投资预算!');
				return;
			}
			if (name == '') {
				this.$util.msg('请输入您的姓名!');
				return;
			}
			if (phone == '') {
				this.$util.msg('请输入您的联系方式!');
				return;
			}
			if (!checkStr(phone, 'mobile')) {
				this.$util.msg('手机号格式错误!');
				return;
			}
			if (remarks == '') {
				this.$util.msg('请填写备注信息,方便工作人员更方便的联系!');
				return;
			}
			const res = await this.$request('user/investment', this.form, { showLoading: true });
			if (res.result == 0) {
				this.$refs.mixModalS.open();
			} else {
				this.$util.msg(res.resultNote);
			}
		}
	}
};
</script>

<style scoped lang="scss">
.pad {
	padding: 0 20rpx;
}
.item-con {
	padding-bottom: 20rpx;
}
.item-title {
	height: 95rpx;
	line-height: 95rpx;
	font-weight: 500;
	color: #666666;
	font-size: 28rpx;
}
.item-input {
	height: 95rpx;
	background: #ffffff;
	/* border: 1px solid rgba(223, 223, 223, 0.26); */
}
.item-textarea {
	background: #ffffff;
	padding: 20rpx;
}
.textarea {
	height: 246rpx;
	width: 100%;
	font-size: 26rpx;
	font-weight: 500;
	color: #999999;
}
.btn {
	width: 704rpx;
	height: 88rpx;
	line-height: 88rpx;
	text-align: center;
	background: $uni-color-bg;
	border-radius: 44rpx;
	font-size: 30rpx;
	font-weight: 500;
	color: #ffffff;
	margin: 50rpx auto;
}
</style>
